/*
 * Copyright (c) 2023, 2024,yzc.cn All rights reserved.
 *
 */
package cn.yzc;

import cn.yzc.employeeListener.EmployeeListener;
import cn.yzc.pojo.Student;
import cn.yzc.server.StudentServer;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.support.ExcelTypeEnum;
import org.junit.jupiter.api.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;


/**
 * <p>Project: EasyExcel - ManyRead</p>
 * <p>Powered by yzc On 2024-03-21 09:50:56</p>
 * <p>描述：<p>
 *
 * @author yzc [youzhicheng0415@163.com]
 * @version 1.0
 * @since 17
 */
//自定义监听器大批量写入
@SpringBootTest
@MapperScan(basePackages = "cn.yzc.mapper")
public class ManyRead {

@Autowired
StudentServer studentServer;

    @Test
    public  void read() {
       //String fileName = TestFileUtil.getPath() + "repeatedWrite批量百万数据.xlsx";
       String fileName = "D:\\JavaProject\\DemoApi\\EasyExcel\\target\\repeatedWrite批量百万数据.xlsx";
        // 这里默认每次会读取100条数据 然后返回过来 直接调用使用数据就行
        // 具体需要返回多少行可以在`PageReadListener`的构造函数设置
        ExcelReader reader =
                EasyExcel.read(fileName, Student.class, new EmployeeListener(studentServer)).excelType(ExcelTypeEnum.XLSX).build();
        ReadSheet sheet =EasyExcel.readSheet().build();
        reader.read(sheet);
    }
}
